// pages/feedback/feedback.js
const API = require("../../common/constant.js");
const util = require("../../utils/util");
const app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    contentValue: ''
  },
  getEventContent (e){
    this.setData({
      content: e.detail.value
    })
  },
  gaveBtn () {
    let that = this;
    if(!this.data.content){
      app.showUserInfo('意见内容不能为空', "none", 1000)
      return;
    }
    wx.showModal({
      title: '意见反馈',
      content: '是否提交',
      success(res){
        console.log(res)
        if (res.confirm){
          that.gaveFreeBack();
        }
      }
    })
  },
  gaveFreeBack () {
    let that = this;
    util.http({
      url: API.URL.USER.ADD_USERFEEDBACK,
      data: {
        feedbackContent: this.data.content
      },
      success(res) {
        app.showUserInfo("提交成功", 'none', 1000);
        that.setData({
          contentValue: ''
        })
      },
      fail(res) {
        app.showUserInfo('res.msg', 'none', 1000);
      }
    })
  }
})